home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 21 / Cream of the Crop 21 (Terry Blount) (October 1996).iso / doom / qplus10.zip / BUTTONS.QC < prev    next >
Text File  |  1996-08-18  |  3KB  |  149 lines

  1. // button and multiple button
  2.  
  3. void() button_wait;
  4. void() button_return;
  5.  
  6. void() button_wait =
  7. {
  8.     self.state = STATE_TOP;
  9.     self.nextthink = self.ltime + self.wait;
  10.     self.think = button_return;
  11.     activator = self.enemy;
  12.     SUB_UseTargets();
  13.     self.frame = 1;            // use alternate textures
  14. };
  15.  
  16. void() button_done =
  17. {
  18.     self.state = STATE_BOTTOM;
  19. };
  20.  
  21. void() button_return =
  22. {
  23.     self.state = STATE_DOWN;
  24.     SUB_CalcMove (self.pos1, self.speed, button_done);
  25.     self.frame = 0;            // use normal textures
  26.     if (self.health)
  27.         self.takedamage = DAMAGE_YES;    // can be shot again
  28.         self.flags = FL_OBJECT;        //ws
  29. };
  30.  
  31.  
  32. void() button_blocked =
  33. {    // do nothing, just don't ome all the way back out
  34. };
  35.  
  36.  
  37. void() button_fire =
  38. {
  39.     if (self.state == STATE_UP || self.state == STATE_TOP)
  40.         return;
  41.  
  42.     sound (self, CHAN_VOICE, self.noise, 1, ATTN_NORM);
  43.  
  44.     self.state = STATE_UP;
  45.     SUB_CalcMove (self.pos2, self.speed, button_wait);
  46. };
  47.  
  48.  
  49. void() button_use =
  50. {
  51.     self.enemy = activator;
  52.     button_fire ();
  53. };
  54.  
  55. void() button_touch =
  56. {
  57.     if (other.classname != "player")
  58.         return;
  59.     if (other.impulse != 14)        //ws
  60.         return;            //ws
  61.     useget = 0;            //ws
  62.  
  63.     self.enemy = other;
  64.     button_fire ();
  65. };
  66.  
  67. void() button_killed =
  68. {
  69.     self.enemy = damage_attacker;
  70.     self.health = self.max_health;
  71.     self.takedamage = DAMAGE_NO;    // wil be reset upon return
  72.     button_fire ();
  73. };
  74.  
  75.  
  76. /*QUAKED func_button (0 .5 .8) ?
  77. When a button is touched, it moves some distance in the direction of it's angle, triggers all of it's targets, waits some time, then returns to it's original position where it can be triggered again.
  78.  
  79. "angle"        determines the opening direction
  80. "target"        all entities with a matching targetname will be used
  81. "speed"        override the default 40 speed
  82. "wait"        override the default 1 second wait (-1 = never return)
  83. "lip"        override the default 4 pixel lip remaining at end of move
  84. "health"        if set, the button must be killed instead of touched
  85. "sounds"
  86. 0) steam metal
  87. 1) wooden clunk
  88. 2) metallic click
  89. 3) in-out
  90. */
  91. void() func_button =
  92. {
  93. local float        gtemp, ftemp;
  94.  
  95.     if (self.sounds == 0)
  96.     {
  97.         precache_sound ("buttons/airbut1.wav");
  98.         self.noise = "buttons/airbut1.wav";
  99.     }
  100.     if (self.sounds == 1)
  101.     {
  102.         precache_sound ("buttons/switch21.wav");
  103.         self.noise = "buttons/switch21.wav";
  104.     }
  105.     if (self.sounds == 2)
  106.     {
  107.         precache_sound ("buttons/switch02.wav");
  108.         self.noise = "buttons/switch02.wav";
  109.     }
  110.     if (self.sounds == 3)
  111.     {
  112.         precache_sound ("buttons/switch04.wav");
  113.         self.noise = "buttons/switch04.wav";
  114.     }
  115.     
  116.     SetMovedir ();
  117.  
  118.     self.movetype = MOVETYPE_PUSH;
  119.     self.solid = SOLID_BSP;
  120.     setmodel (self, self.model);
  121.  
  122.     self.blocked = button_blocked;
  123.     self.use = button_use;
  124.     self.flags = FL_OBJECT;        //ws
  125.  
  126.     if (self.health)
  127.     {
  128.         self.max_health = self.health;
  129.         self.th_die = button_killed;
  130.         self.takedamage = DAMAGE_YES;
  131.         self.flags = FL_OBJECT;            //ws
  132.     }
  133.     else
  134.         self.touch = button_touch;
  135.  
  136.     if (!self.speed)
  137.         self.speed = 40;
  138.     if (!self.wait)
  139.         self.wait = 1;
  140.     if (!self.lip)
  141.         self.lip = 4;
  142.  
  143.     self.state = STATE_BOTTOM;
  144.  
  145.     self.pos1 = self.origin;
  146.     self.pos2 = self.pos1 + self.movedir*(fabs(self.movedir*self.size) - self.lip);
  147. };
  148.  
  149.